package com.ymatou.query.trading.api.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.trading.api.parameter.GetOrderCountOfPlatformBean;
import com.ymatou.query.trading.api.service.GetOrderCountOfPlatformCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.common.enums.PlatformEnum;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.constant.ECode;

/**
 * 获取不同平台上面的订单数量 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetOrderCountOfPlatform {
	private static GetOrderCountOfPlatformBean gocopbean;
	private static GetOrderCountOfPlatformCall gocopcall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取不同平台上面的订单数量");
	}

	@Before
	public void caseUp() {
		gocopbean = new GetOrderCountOfPlatformBean();
		gocopcall = new GetOrderCountOfPlatformCall();

	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(gocopcall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderCountOfPlatform_001() {
		Logger.start(true,"获取不同平台上面的订单数量成功");
		try {
			int UserId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("买家ID:" + UserId);
			gocopbean.setBuyerId(UserId);
			// 订单来源
			Logger.comment("订单来源:" + PlatformEnum.Ymt_PC);
			gocopbean.setPlatformType(null);
			// 发送请求
			gocopcall.setData(gocopbean);
			gocopcall.callService();
			Logger.comment("gocopcall send:" + gocopcall.getEntityString());
			Logger.comment("gocopcall response:" + gocopcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, gocopcall.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG2, gocopcall.getMsg(),
			// "验证Msg");
			Logger.verifyEquals(true, (gocopcall.getOrderNum().get(PlatformEnum.Ymt_PC)) > 0, "判断PC订单数量大于0");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}